package com.naive.imperative.program;


public class Conditional extends Operation {
	private EvaluatableOperation<Boolean> ifStatement;
	private OperationBlock trueBlock;
	private OperationBlock falseBlock;
	
	@Override
	public void execute(ExecutionContext x) {
		x.beforeConditional(this);
		Boolean b = ifStatement.evaluate(x);
		if (b) {
			trueBlock.execute(x);
		} else {
			falseBlock.execute(x);
		}
		x.afterConditional(this);
	}

	public EvaluatableOperation<Boolean> getIfStatement() {
		return ifStatement;
	}

	public void setIfStatement(EvaluatableOperation<Boolean> ifStatement) {
		this.ifStatement = ifStatement;
	}

	public OperationBlock getTrueBlock() {
		return trueBlock;
	}

	public void setTrueBlock(OperationBlock trueBlock) {
		this.trueBlock = trueBlock;
	}

	public OperationBlock getFalseBlock() {
		return falseBlock;
	}

	public void setFalseBlock(OperationBlock falseBlock) {
		this.falseBlock = falseBlock;
	}
	
}
